<%@ page import="vy.org.app.common.*" %>
<%@ page import="java.util.Map.*" %>
<%@ page import="java.util.*" %>

<%
	String sesModuleGrpId = request.getParameter(AppConstants.QUERY_PARAM_MENU_ID); 
	if(sesModuleGrpId == null){
		sesModuleGrpId = (String)session.getAttribute(AppConstants.SESSION_MENU_ID);
	} else {
		session.setAttribute(AppConstants.SESSION_MENU_ID, sesModuleGrpId);
	}
	m_user = ActionCtx.ctx(request).getUser();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Left Menu</title>
<link rel="stylesheet" type="text/css" href="../css/Common.css">
<script type="text/javascript" src="../scripts/Common.js"></script>
	<style>
		body{margin:0;padding:0;background-color:#fff;}
		a.menu-btn {display:block;width:100%;padding:5px 25px 5px;color:#000;
			font-size:12px;font-family:Arial;white-space:nowrap;text-decoration:none;}
		a.menu-btn:hover {color:#222;background:#ccc;text-decoration:none;font-family:Arial;}
		.ocnt {background:#e8e8e8;height:310px;overflow:auto;overflow-x:hidden;}
	</style>
</head>

<body>

<table style="margin:5px 0" border="0" width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td width="180px">
				<center><img border="0" src="./images/logo-aa.jpeg" height="95"></center>
		</td>
	</tr>
</table>

<div class="ec">
<%
	int i=0,idx=0;
	Map<Object, BaseEnum> menuModelMap = MenuModelMapEnum.get(MenuModelMapEnum.class);
	Set<Entry<Object, BaseEnum>> menuMapSet = menuModelMap.entrySet();
	for(Entry<Object, BaseEnum> menuMap : menuMapSet){
		MenuModelMapEnum menuModelEnum = (MenuModelMapEnum)menuMap.getValue();
		List<Integer> modules = menuModelEnum.getModules();
		i=0;
		for(Integer mod : modules){
			if(mod.intValue() >= 100 && mod.intValue() < 10000)
				continue;
			
			if(hasModuleAccess(mod)){
				if(i==0){
					i++;
					idx++;
				%>
					<div onclick="toggleSlideShowHide('ech<%=idx %>','ecco<%=idx %>','ecci<%=idx %>','ec-ex','ec-co');" onfocus="toggleSlideShowHide('ech<%=idx %>','ecco<%=idx %>','ecci<%=idx %>','ec-ex','ec-co');" class="ec-ttl <%=(idx==1?"ec-ex":"ec-co")%>" style="" tabindex="0" id="ech<%=idx %>">
						<label><%=menuModelEnum.getDisplayName() %></label></div>
					<div style="height: <%=(idx==1?"auto":"0px")%>" class="ec-outer" id="ecco<%=idx %>">
						<div class="ec-inner ec-cnt" id="ecci<%=idx %>">
							<div class="ocnt">
					<%
				}
				ModuleEnum mMenu = (ModuleEnum)ModuleEnum.get(mod, ModuleEnum.class);
				%>
				
				<a name="<%=mMenu.getName()%>" href="<%=Config.getAppPath() + mMenu.getUrl() %>#<%=mMenu.getName()%>" class="menu-btn" target="content"><%=mMenu.getDisplayName() %></a>				
				<%
			}
		}
		if(i == 1){
			i++;
		%>
					</div>
				</div>
			</div>
		<%			
		}
	}
%>
</div>	

</body>
</html>

<%!
	MenuModelMapEnum m_mMapEnum = null;
	UserCtx m_user = null;
	
	private boolean hasModuleAccess(Object mod){
		return m_user.hasAccessToModule(mod.toString());		
	}
%>
